<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>06-一个循环画表格</title>
    <style>
        canvas{
            border: 1px solid #000;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="800" height="600"></canvas>
    <script>
        var canvas = document.getElementById("canvas")
        var ctx = canvas.getContext("2d")
        ctx.strokeRect(0,0,20,20)
        var i = 0,j = 0
        drawtable(ctx,20)
        function drawtable(ctx,w) {
            for (; i < 50; i++) {
                ctx.strokeRect(i*w,j*w,w,w)
                if (i==49) {
                    i=-1
                    j++
                    if (j == 49) {
                        break
                    }
                }
            }
        }

    </script>
</body>
</html>